package model;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "ChiTietNXB_Sach")
public class ChiTietNXB_Sach {
	private ChiTietNXB_SachID chiTietNXB_SachID;

	private Sach sach;
	private NhaXuatBan nxb;

	// public ChiTietNXB_Sach(ChiTietNXB_SachID chiTietNXB_SachID) {
	// super();
	// this.chiTietNXB_SachID = chiTietNXB_SachID;
	// }

	public ChiTietNXB_Sach(ChiTietNXB_SachID chiTietNXB_SachID, Sach sach,
			NhaXuatBan nxb) {
		super();
		this.chiTietNXB_SachID = chiTietNXB_SachID;
		this.sach = sach;
		this.nxb = nxb;
	}
	public ChiTietNXB_Sach(ChiTietNXB_SachID chiTietNXB_SachID) {
		super();
		this.chiTietNXB_SachID = chiTietNXB_SachID;
	}
	public ChiTietNXB_Sach(){
		
	}

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "ID_Sach", column = @Column(name = "ID_Sach", nullable = false)),
			@AttributeOverride(name = "ID_NXB", column = @Column(name = "ID_NXB", nullable = false)) })
	public ChiTietNXB_SachID getChiTietNXB_SachID() {
		return chiTietNXB_SachID;
	}

	public void setChiTietNXB_SachID(ChiTietNXB_SachID chiTietNXB_SachID) {
		this.chiTietNXB_SachID = chiTietNXB_SachID;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_Sach", nullable = false, insertable = false, updatable = false)
	public Sach getSach() {
		return sach;
	}

	public void setSach(Sach sach) {
		this.sach = sach;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_NXB", nullable = false, insertable = false, updatable = false)
	public NhaXuatBan getNxb() {
		return nxb;
	}

	public void setNxb(NhaXuatBan nxb) {
		this.nxb = nxb;
	}

}
